package com.lecyon.farm.common.enums;

import com.lecyon.farm.util.StringHelper;
import lombok.Getter;

/**
 * 用户状态
 *
 * @author Yao Zheng
 * @Date 2019/12/10 16:56
 */
public enum UserStatusEnum {

    //正常
    ACTIVE("0", "正常"),
    //删除
    DELETE("1", "删除"),
    //停用
    INACTIVE("2", "停用"),
    //冻结
    FREEZE("3", "冻结");


    @Getter
    private String statusValue;

    @Getter
    private String statusCode;

    UserStatusEnum(String statusCode, String statusValue) {
        this.statusCode = statusCode;
        this.statusValue = statusValue;
    }

    /**
     * 根据状态值获取状态代码
     *
     * @param statusCode 状态值
     * @return 状态
     */
    public static UserStatusEnum getByValue(String statusCode) {
        if (StringHelper.isNotEmpty(statusCode)) {
            for (UserStatusEnum statusEnum : values()) {
                if (statusEnum.statusCode.equals(statusCode)) {
                    return statusEnum;
                }
            }
        }
        return null;
    }
}
